#include "main.h"

void input_person_info(struct person *p1)
{
    int ret;
retry:
    printf("input (name,sex,score) > ");
    //scanf的返回值是输入成功的项目的个数,这里的%s %c %d共三个选项
    ret = scanf("%s %c %d",p1->name,&p1->sex,&p1->score);
    if(ret != 3){
        printf("input error,try again\n");
        while(getchar()!='\n'); //吃掉垃圾字符
        goto retry;
    }
}
//因为在函数中不需要对main函数中的p1进行修改，所以直接进行值传递即可
//结构体变量可以直接复制
void show_person_info(struct person p1)
{
    printf("name = %s,sex = %c,score = %d\n",p1.name,
    p1.sex,p1.score);
}